package com.appspot.igo8poi.controller;

import com.appspot.igo8poi.model.bean.UserInfo;
import com.appspot.igo8poi.service.UserManager;

public class BaseController {
	private UserManager userManager = UserManager.getInstance();

	protected UserInfo getUser() {
		return userManager.getCurrentUser();
	}

	protected String getUserId() {
		return getUser().getUserId();
	}

	protected boolean isUserAdmin() {
		return userManager.isUserAdmin();
	}

	protected String exceptionDetails(Exception e) {
		StringBuffer exceptionDetails = new StringBuffer();
		String message = e.getMessage();
		exceptionDetails.append(null == message ? "null" : message);
		StackTraceElement[] stackTrace = e.getStackTrace();
		for (StackTraceElement element : stackTrace) {
			exceptionDetails.append("\n\t");
			exceptionDetails.append(element.toString());
		}
		return exceptionDetails.toString();
	}
}
